﻿{% extends "guild/base.html" %}
{% load mytag %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__bd">
    <div class="weui-cells__title">基本数据</div>
    <div class="weui-cells">
        {% if user.avatar %}
        <a class="weui-cell weui-cell_access" href="{% url 'guild:gallery' user.avatar %}">
            <div class="weui-cell__bd"> <p>头像</p> </div>
            <div class="weui-cell__ft"> <img src="{{ user.avatar|cdn }}" class="right_large_avatar"> </div>
        </a>
        {% endif %}

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>用户id</p> </div>
            <div class="weui-cell__ft">{{ user.id }}</div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>昵称</p> </div>
            <div class="weui-cell__ft">{{ user.auth_nickname }}</div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>个性签名</p> </div>
            <div class="weui-cell__ft">{{ user.signature }}</div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>自我评价</p> </div>
            <div class="weui-cell__ft">{{ user.tags }}</div>
        </div>

         <div class="weui-cell">
            <div class="weui-cell__bd"> <p>自我介绍</p> </div>
            <div class="weui-cell__ft">{{ user.introduction }}</div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>登录手机</p> </div>
            <div class="weui-cell__ft">
            {{ user.last_login_version }}
            {% if is_ios_device %}
                <i class="fab fa-apple weui_grid_icon_fa_red"></i>
            {% else %}
                <i class="fab fa-android weui_grid_icon_fa"></i>
            {% endif %}
            </div>
        </div>
    </div>

    <div class="weui-cells__title">资料审核</div>
    <div class="weui-cells">
        <a class="weui-cell weui-cell_access" href="{% url 'guild:caster_video_list' user.id %}">
            {% if total_video_count > 0 %}
            <div class="weui-cell__bd">
                <p>
                    <i class="fa fa-video"></i> 视频({{ total_video_count }})
                    {% if waiting_auth_video_count > 0 %}
                        <span class="weui-badge" style="margin-left: 5px;">{{ waiting_auth_video_count }}</span>
                    {% endif %}
                </p>
            </div>
            {% else %}
            <div class="weui-cell__bd">
                <p>
                    <i class="fa fa-video"></i> 视频
                    {% if waiting_auth_video_count > 0 %}
                        <span class="weui-badge" style="margin-left: 5px;">{{ waiting_auth_video_count }}</span>
                    {% endif %}
                </p>
            </div>
            {% endif %}

            <div class="weui-cell__ft">
                <ul class="weui-uploader__files">
                    {% for video in sample_videos %}
                    <li class="weui-uploader__file" style="background-image:url({{ video.cover_url }})"></li>
                    {% endfor %}
                </ul>
            </div>
        </a>

        <a class="weui-cell weui-cell_access" href="{% url 'guild:caster_album' user.id %}">
            {% if user.images|length > 0 %}
            <div class="weui-cell__bd">
                <p>
                    <i class="fa fa-images"></i> 相册({{ user.images|length }})
                    {% if auth_photo %}
                        <span class="weui-badge" style="margin-left: 5px;">!</span>
                    {% endif %}
                </p>
            </div>
            {% else %}
            <div class="weui-cell__bd">
                <p>
                    <i class="fa fa-images"></i> 相册
                    {% if auth_photo %}
                        <span class="weui-badge" style="margin-left: 5px;">!</span>
                    {% endif %}
                </p>
            </div>
            {% endif %}

            <div class="weui-cell__ft">
                <ul class="weui-uploader__files">
                    {% for image in sample_images %}
                    <li class="weui-uploader__file" style="background-image:url({{ image|cdn }})"></li>
                    {% endfor %}
                </ul>
            </div>
        </a>
    </div>

    <div class="weui-cells__title">直播设置</div>
    <div class="weui-cells">
        <div class="weui-cell" id="showIOSActionSheet">
            <div class="weui-cell__bd"> <p>直播价格</p> </div>
            <div class="weui-cell__ft">{{ user.price }}钻石/分钟</div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p> 勿扰 </p> </div>
            <div class="weui-cell__ft">
                <label for="switch_busy_mode" class="weui-switch-cp">
                    <input id="switch_busy_mode" class="weui-switch-cp__input" type="checkbox" {{ is_busy }} onclick="clickBusyModeSwitch()" />
                    <div class="weui-switch-cp__box"></div>
                </label>
            </div>
        </div>
    </div>

    <div class="weui-cells__title">统计数据</div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd"> <p> 剩余钻石 </p> </div>
            <div class="weui-cell__ft"> {{ user.diamond }} <i class="fa fa-gem"></i> </div>
        </div>

         <div class="weui-cell">
            <div class="weui-cell__bd"> <p> 剩余趣票 </p> </div>
            <div class="weui-cell__ft"> {{ user.ticket }} <i class="fa fa-ticket-alt"></i> </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>累计在线</p> </div>
            <div class="weui-cell__ft"> {{ total_online_seconds|readable_seconds }} </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>累计通话</p> </div>
            <div class="weui-cell__ft"> {{ total_call_seconds|readable_seconds }} </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>累计收益</p> </div>
            <div class="weui-cell__ft"> {{ total_income }} <i class="fa fa-ticket-alt"></i> </div>
        </div>
    </div>
</div>

    <div class="weui-mask" id="iosMask" style="display: none"></div>
    <div class="weui-actionsheet" id="iosActionsheet">
        <div class="weui-actionsheet__title">
            <p class="weui-actionsheet__title-text">设置通话价格</p>
        </div>
        <div class="weui-actionsheet__menu">
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(0)"> <b>0</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(3)"> <b>3</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(5)"> <b>5</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(8)"> <b>8</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(10)"> <b>10</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(12)"> <b>12</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(18)"> <b>18</b> 钻石/分钟</div>
            <div class="weui-actionsheet__cell" onclick="javascript:set_cast_price(20)"> <b>20</b> 钻石/分钟</div>
        </div>
        <div class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="iosActionsheetCancel">取消</div>
        </div>
    </div>

<div class="weui-btn-area">
    {% if liveid > 0 %}
    <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:shutdownChannel()"> <i class="fa fa-phone-slash"></i> 关闭通话 </a>
    {% endif %}

    <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:leaveGuild()"> <i class="fa fa-door-open"></i> 请离公会 </a>
</div>

<div class="page__ft">
    <a href="{% url 'guild:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>

{% endblock content %}

<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script type="text/javascript" class="actionsheet js_show">
$(function(){
    let $iosActionsheet = $('#iosActionsheet');
    let $iosMask = $('#iosMask');

    function hideActionSheet() {
        $iosActionsheet.removeClass('weui-actionsheet_toggle');
        $iosMask.fadeOut(200);
    }

    $iosMask.on('click', hideActionSheet);
    $('#iosActionsheetCancel').on('click', hideActionSheet);
    $("#showIOSActionSheet").on("click", function(){
        $iosActionsheet.addClass('weui-actionsheet_toggle');
        $iosMask.fadeIn(200);
    });
});

function set_cast_price(price) {
    let url = "{% url 'gma:api_set_cast_price' %}";
    let data = {
        'uid': {{ user.id }},
        'price': price,
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`直播价格设置为${price}钻石!`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}
</script>

<script>
function shutdownChannel() {
    let url = "{% url 'gma:api_shutdown_channel' %}";
    let data = {
        'channel_name': '{{ liveid }}',
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`关闭当前通话!`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}

function leaveGuild() {
    show_confirm_dialog('请离公会', '你确定将{{ user.auth_nickname }}请离公会吗?', ()=> {
        let url = "{% url 'gma:api_leave_guild' %}";
        let data = {
            'uid': {{ user.id }},
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`{{ user.auth_nickname }}被从公会中移除!`);
            setTimeout(() => {
                window.location = "{% url 'guild:members' %}";
            }, 1000);
        });
    });
}

function clickBusyModeSwitch() {
    let url = "{% url 'gma:api_set_user_is_busy' %}";

    if ($('#switch_busy_mode').is(':checked')) {
        let data = {
            'uid': {{ user.id }},
            'is_busy': 1,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`开启勿扰模式!`);

        });
    } else {
        let data = {
            'uid': {{ user.id }},
            'is_busy': 0,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`关闭勿扰模式!`);

        });
    }
}
</script>

{% endblock extra_js %}
